//
//  UIScreen+LYAdd.m
//  LYDevelopKit
//
//  Created by 李阳 on 2018/5/25.
//

#import "UIScreen+LYAdd.h"
#import "LYUIMacros.h"

LYSYNTH_DUMMY_CLASS(UIScreen_LYAdd)

@implementation UIScreen (LYAdd)

+ (CGFloat)scaleAsIPhone6
{
    static CGFloat scale = 0.0;
    static dispatch_once_t onceToken;
    dispatch_once(&onceToken, ^{
        if ([NSThread isMainThread])
        {
            scale = [[UIScreen mainScreen] bounds].size.width / 375.0;
        }
        else
        {
            dispatch_sync(dispatch_get_main_queue(), ^{
                scale = [[UIScreen mainScreen] bounds].size.width / 375.0;
            });
        }
    });
    return scale;
}

/// 相对于iPhone6缩放后的单精度浮点值
+ (CGFloat)floatScreenValueWith:(CGFloat)value
{
    return round(value * [self scaleAsIPhone6] * 10) / 10;
}
/// 相对于iPhone6缩放后的双精度浮点值
+ (CGFloat)doubleScreenValueWith:(CGFloat)value
{
    return round(value * [self scaleAsIPhone6] * 100) / 100;
}


@end
